The present invention relates to database cursors, and more specifically, to dynamically adjusting the maximum number of cursors for a database job or within a database system, and intelligently selecting cursors to close when the limit is reached.
In many database management systems (DMBS), query cursors (or database cursors) are used to traverse over and access records in the database as required by various jobs, threads, applications, and users.
Frequently, once a cursor has been created, it is saved so that future queries may reuse it, for example, if the same query is run again. In this way, future queries can be completed more quickly as the system does not need to rebuild a cursor each time the same query is received by the database system. In addition to saving time, reusing cursors helps to reduce the processing and memory resources needed by future queries.
At any given time, it is common to have a large number of cursors open on a database system, as there may be hundreds or thousands of jobs, threads, applications, and users accessing the same database, and each may open hundreds or thousands of cursors. Thus as the workload grows, the DBMS may begin to be burdened by the excessive number of cursors that have not been closed, for example, the system may run out of RAM or may generally suffer from poorer performance due to the number of database cursors that are open.